import Vue from 'vue'
import Vuex from 'vuex'
import axios from "axios";
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list:[],
    showList:[],
  },
  mutations: {
    INIT_LIST(state,item){
      state.list = [...item]
    }
  },
  actions: {
    DATA_LIST(context){
      axios.get("http://localhost:8080/list.json").then((res)=>{
      // console.log(res);
        context.commit("INIT_LIST",res.data)
      })
    }
  },
  getters:{
    showLista:function(state){
      var tempArray = [];
      for(let index=0;index<10;index++){
        tempArray.push(state.list[index])
      }
      return tempArray;
    }
  },
  modules: {
  }
})
